<?php
// +----------------------------------------------------------------------
// | User: DaMing
// +----------------------------------------------------------------------
// | Email: 3228985941@qq.com
// +----------------------------------------------------------------------
// | Date: 2021/12/12
// +----------------------------------------------------------------------
// | Time: 21:59
// +----------------------------------------------------------------------
use think\facade\Route;
use think\facade\Config;
use think\Response;

/**
 * 无需授权的接口
 */
Route::group(function () {
    // 测试路由
    Route::get('test', 'Test/index');
    // token测试路由
    Route::get('token', 'Test/token');
})->allowCrossDomain();


/**
 * 需要授权的接口
 */
Route::group(function () {
    // 权限测试路由
    Route::get('authTest', 'Test/auth');

})->allowCrossDomain()->middleware('AdminAuth');

/**
 * miss 路由
 */
//Route::miss(function () {
//    if (app()->request->isOptions()) {
//        $header = Config::get('cookie.header');
//        $header['Access-Control-Allow-Origin'] = app()->request->header('origin');
//        return Response::create('ok')->code(200)->header($header);
//    } else
//        return Response::create()->code(404);
//});
